//
//  NSArray+SafeAccess.h
//  IOS-Categories
//
//  Created by Jakey on 15/2/8.
//  Copyright (c) 2015年 www.skyfox.org. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

@interface NSArray (OF)
+(NSMutableArray *)onSeparatedByArr:(NSArray *)array;
@end

@interface NSArray (SafeAccess)
-(id)objectWithIndex:(NSUInteger)index;

- (NSString*)stringWithIndex:(NSUInteger)index;

- (NSNumber*)numberWithIndex:(NSUInteger)index;

- (NSArray*)arrayWithIndex:(NSUInteger)index;

- (NSDictionary*)dictionaryWithIndex:(NSUInteger)index;

- (NSInteger)integerWithIndex:(NSUInteger)index;

- (NSUInteger)unsignedIntegerWithIndex:(NSUInteger)index;

- (BOOL)boolWithIndex:(NSUInteger)index;

- (int16_t)int16WithIndex:(NSUInteger)index;

- (int32_t)int32WithIndex:(NSUInteger)index;

- (int64_t)int64WithIndex:(NSUInteger)index;

- (char)charWithIndex:(NSUInteger)index;

- (short)shortWithIndex:(NSUInteger)index;

- (float)floatWithIndex:(NSUInteger)index;

- (double)doubleWithIndex:(NSUInteger)index;

//CG
- (CGFloat)CGFloatWithIndex:(NSUInteger)index;

- (CGPoint)pointWithIndex:(NSUInteger)index;

- (CGSize)sizeWithIndex:(NSUInteger)index;

- (CGRect)rectWithIndex:(NSUInteger)index;
@end


#pragma --mark NSMutableArray setter

@interface NSMutableArray(SafeAccess)

-(void)addObj:(id)i;

-(void)addString:(NSString*)i;

-(void)addBool:(BOOL)i;

-(void)addInt:(int)i;

-(void)addInteger:(NSInteger)i;

-(void)addUnsignedInteger:(NSUInteger)i;

-(void)addCGFloat:(CGFloat)f;

-(void)addChar:(char)c;

-(void)addFloat:(float)i;

-(void)addPoint:(CGPoint)o;

-(void)addSize:(CGSize)o;

-(void)addRect:(CGRect)o;
@end


@interface NSArray (Block)
/**
 *  便利数组
 */
- (void)each:(void (^)(id))block;
/*
 从数组中筛选，在返回
 */
- (NSArray* )select:(BOOL (^)(id))block;
/*
 从数组中筛选，返回数组，没有筛选的，用别的替换
 */
- (NSArray *)map:(id (^)(id))block;
/*
 从数组中选择某个ID开始,在拼接后面数组便利的数
 */
- (id)reduce:(id)initial withBlock:(id (^)(id,id))block;
@end


@interface NSArray (data)
/** <将array转data> */
-(NSData *)onDataByArray;
@end



@interface NSArray (string)
-(NSString *)onStringByArrayJoined:(NSString *)string;
@end

@interface NSArray (compare)
//判断这个数组是非包含另一个数组的元素
-(BOOL)containArray:(NSArray*)array;
@end